package com.vhall.component.controller.room;

import com.alibaba.fastjson.JSONObject;
import com.vhall.component.controller.room.facade.RoomFacade;
import com.vhall.component.entity.room.vo.*;
import com.vhall.component.framework.common.annotation.VhallComponent;
import com.vhall.component.framework.common.exception.BusinessException;
import com.vhall.component.plugin.common.annotation.TokenAuth;
import com.vhall.component.plugin.common.annotation.VssTokenAuth;
import com.vhall.component.plugin.common.exception.BizErrorCode;
import com.vhall.component.plugin.common.support.TokenThreadLocal;
import com.vhall.component.service.room.RoomService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @author guoxin.wang
 * @date 2021/7/12 17:30
 */
@Slf4j
@VhallComponent
public class RoomController implements RoomFacade {

    @Autowired
    private RoomService roomService;

    @Override
    @VssTokenAuth
    public RoomAttrRespVO getAttributes(RoomAttrVO reqVO) {
        return roomService.getAttributes(reqVO);
    }

    @Override
    @VssTokenAuth
    public RoomExtendRespVO getRoomExtendsInfo(RoomAttrVO reqVO) {
        return roomService.getRoomExtendsInfo(reqVO);
    }

    @Override
    public JSONObject customMenu(CustomMenuListVO reqVO) {
        return roomService.listCustomMenu(reqVO);
    }

    @Override
    @VssTokenAuth
    public Boolean startLive(StartLiveVO reqVO) {
        return roomService.startLive(reqVO);
    }

    @Override
    public Boolean genDefaultRecord(EndLiveVO reqVO) {
        return roomService.genDefaultRecord(reqVO);
    }

    @Override
    @VssTokenAuth
    public Boolean endLive(EndLiveVO reqVO) {
        return roomService.endLive(reqVO);
    }

    @Override
    @VssTokenAuth
    public RoomDetailRespVO getRoomDetail(RoomAttrVO reqVO) {
        return roomService.getRoomDetail(reqVO);
    }

    @Override
    @VssTokenAuth
    public Boolean masterStatusNotice(MasterStatusNoticeVO reqVO) {
        if (!(reqVO.getStatus() == 0 || reqVO.getStatus() == 1)) {
            throw new BusinessException(BizErrorCode.COMP_TAG_STATUS_NOT_ALLOWED);
        }
        return roomService.masterStatusNotice(reqVO);
    }

    @Override
    @TokenAuth
    public Integer isAnchor(CheckIsAnchorReqVO reqVO) {
        return roomService.checkIsAnchor(TokenThreadLocal.getToken().getAccountId(), reqVO.getRoomId());
    }

    @Override
    public JSONObject submitVODToLive(SubmitVODToLiveVO reqVO) {
        return roomService.submitVODToLive(reqVO);
    }

    @Override
    public JSONObject getStreamStatus(String roomIds) {
        return roomService.getStreamStatus(roomIds);
    }

    @Override
    @TokenAuth
    public Boolean judgeReservationOrNot(CheckIsAnchorReqVO reservationVO) {
        return roomService.judgeReservationOrNot(reservationVO);
    }

    @Override
    @TokenAuth
    public Boolean reservationOrNot(ReservationVO reservationVO) {
        return roomService.reservationOrNot(reservationVO);
    }

    @Override
    @VssTokenAuth
    public ReportRoomRspVO reportRoom(ReportRoomReqVO vo) {
        return roomService.reportRoom(vo);
    }

    @Override
    public List<ReportConfigRspVO> getReportConfigList(ReportConfigReqVO vo) {
        return roomService.getReportConfigList(vo);
    }

    @Override
    public String getHaveSDKVersion() {
        return roomService.getHaveSDKVersion();
    }

    @Override
    public Boolean settingHaveSDKVersion(String version) {
        return roomService.settingHaveSDKVersion(version);
    }

    @Override
    public RoomLimitTypeRspVO getLimitType(String roomId) {
        return roomService.getLimitType(roomId);
    }

    @Override
    public RiskWarningSmallVO getRoomRiskWarning(String roomId) {
        return roomService.getRoomRiskWarning(roomId);
    }

    @TokenAuth
    @Override
    public LiveWatchCheckResponseVO liveWatchLimit(LiveWatchCheckRequestVO vo) {
        return roomService.liveWatchCheck(vo);
    }
    @TokenAuth
    @Override
    public Boolean setBeautyCoefficient(Integer number) {
        return roomService.setBeautyCoefficient(number);
    }
    @TokenAuth
    @Override
    public Integer getBeautyCoefficient() {
        return roomService.getBeautyCoefficient();
    }
    @Override
    public Long getVirtualPV(Integer ilId) {
        return roomService.getVirtualPV(ilId);
    }
}
